CC = g++
CFLAGS = -c -Wall -ansi -pedantic -std=c++11
LDFLAGS =

SRCDIR = src
SRC = $(SRCDIR)/arc.cpp $(SRCDIR)/noeud.cpp $(SRCDIR)/element_generique.cpp $(SRCDIR)/liste.cpp $(SRCDIR)/graphe.cpp
MAIN = main.cpp
OBJECTS=$(SRC:.cpp=.o)
MAINBIN = $(MAIN:.cpp=.o)

BINDIR = bin
EXEC = $(BINDIR)/graphe

SYS := $(shell gcc -dumpmachine)
ifneq (, $(findstring linux, $(SYS)))
 #EXEC = graphe
else ifneq (, $(findstring mingw, $(SYS)))
    EXEC = $(BINDIR)/graphe.exe
else ifneq (, $(findstring cygwin, $(SYS)))
    EXEC = $(BINDIR)/graphe.exe
 # Do cygwin things
else
 # Do things for others
endif

all: $(SRC) $(EXEC)

run: all
	$(EXEC)

$(EXEC): $(OBJECTS) $(MAINBIN)
	$(CC) $(LDFLAGS) $(OBJECTS) $(MAINBIN) -o $@

$(MAINBIN): $(OBJECTS) $(MAIN)
	$(CC) $(CFLAGS) $(MAIN) -o $@

.cpp.o:
	$(CC) $(CFLAGS) $< -o $@


clean:
	rm -f $(EXEC) $(OBJECTS)

valmem:
	valgrind --tool=memcheck ./$(EXEC)

valleak:
	valgrind --leak-check=full ./$(EXEC)

keyboardcat:
	firefox http://www.youtube.com/watch?v=J---aiyznGQ &
